package com.antgroup.seckill.business.goods.controller;


import com.antgroup.seckill.business.common.enums.RespBeanEnum;
import com.antgroup.seckill.business.common.vo.response.OrderDetailVo;
import com.antgroup.seckill.business.common.vo.response.RespBean;
import com.antgroup.seckill.business.goods.model.User;
import com.antgroup.seckill.business.goods.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Objects;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author wangxy
 * @since 2024-07-30
 */
@Controller
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private IOrderService orderService;


    @GetMapping("/orderDetail")
    @ResponseBody
    public RespBean getOrderDetail(User user, @RequestParam String orderId) {
        if (Objects.isNull(user)) {
            return RespBean.error(RespBeanEnum.NOT_LOGIN);
        }

        OrderDetailVo detailVo = orderService.queryOrderDetailByOrderId(orderId);
        detailVo.setUser(user);
        return RespBean.success(detailVo);
    }

}
